const path = require('path')
const resolve = dir => {
  return path.join(__dirname, dir)
}

const port = process.env.port || process.env.npm_config_port || 80 // 端口

module.exports = {
  publicPath: './',
  // css: {
  //   loaderOptions: {
  //     sass: {
  //       // sassOptions: { outputStyle: "expanded" }
  //       prependData: `@import "@/assets/scss/mixin.scss"` // 新版scss-loader(8.0及以上)
  //     }
  //   }
  // },
  productionSourceMap: false,

  // webpack-dev-server 相关配置
  devServer: {
    host: '0.0.0.0',
    port: port,
    open: true,
    proxy: {
      // detail: https://cli.vuejs.org/config/#devserver-proxy
      [process.env.VUE_APP_BASE_API]: {
        // target: `http://localhost:8080`,
        target: `http://127.0.0.1:8080`,
        // target: `http://111.36.47.42:8880/prod-api`,
        // target: `http://192.1.3.209/prod-api`,
        // target: `http://192.168.68.230:8080`,
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API]: ''
        }
      },
      // '/defop': {
      //       //   target: 'http://10.11.203.92:8080',
      //       //   ws: false,
      //       //   changeOrigin: true,
      //       //   pathRewrite: {
      //       //     '^/defop': '/defop'
      //       //   }
      //       // },
    },
    disableHostCheck: true
  },
  chainWebpack: config => {
    config.resolve.alias
      .set('_c', resolve('src/components')) // key,value自行定义，比如.set('@@', resolve('src/components'))
  },
}
